import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '考试名',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '试卷',
    align: "center",
    dataIndex: 'paperId_dictText'
  },
  {
    title: '开始时间',
    align: "center",
    dataIndex: 'limitStartTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '结束时间',
    align: "center",
    dataIndex: 'limitEndTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '考试限时',
    align: "center",
    dataIndex: 'suggestTime'
  },
  {
    title: '创建用户',
    align: "center",
    dataIndex: 'createUserId'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '考试名',
    field: 'name',
    component: 'Input',
  },
  {
    label: '试卷',
    field: 'paperId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "oes_paper,name,id"
    },
  },
  {
    label: '开始时间',
    field: 'limitStartTime',
    component: 'DatePicker',
  },
  {
    label: '结束时间',
    field: 'limitEndTime',
    component: 'DatePicker',
  },
  {
    label: '考试限时',
    field: 'suggestTime',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: false},
              { pattern: '^[1-9]\d*$', message: '不符合校验规则!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
